﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Imaging;
using System.Windows.Navigation;
using System.Windows.Shapes;
using AnesSystem.Models;

namespace AnesSystem.Controls
{
    /// <summary>
    /// TableCellCtrl.xaml 的交互逻辑
    /// </summary>
    public partial class TableCellCtrl : RealVitalIcon
    {
        public TableCellCtrl()
        {
            this.Height = 15;
            this.Width = 30;
            Background = Brushes.Transparent;
            InitializeComponent();
        }

        public override void ResizeIcon()
        {
            
        }

        protected override int CalValue2Yplot(PatientVitalSignsModel iItem)
        {
            return LocationUtil.RealTimeSignItem_Height * Index;
        }
       
        protected override int CalValue2Xplot(PatientVitalSignsModel value)
        {
            if (Constants.ISLABOR.Equals(DataManager.Instance.IsInAorP))
            {
                int index = value.LaborIndex;
                if (index <= 12)
                {
                    return (int)(index * LocationUtil.RealTimeItem_Width);
                }
                else
                {
                    return (int)(((index - 12) + index) * LocationUtil.RealTimeItem_Width);
                }
            }
            else {
            DateTime startTime = new DateTime();
            if (value.IsAorP.Equals(Constants.ISANES))
            {
                DateTime anesRecordTime = DataManager.Instance.CurrentPatientLink.Status.AnesRecordStartTime;
                startTime= anesRecordTime.AddHours((CurPage - 1) * 4);
            }
            if (value.IsAorP.Equals(Constants.ISPACU))
            {
                DateTime pacuRecordTime = DataManager.Instance.CurrentPatientLink.Status.PacuStartTime;
                startTime= pacuRecordTime.AddHours((CurPage - 1) * 4);
            }
            TimeSpan span = value.CaptureTime - startTime;
            int span1 = span.Minutes + span.Hours * 60 + span.Days * 24 * 60;
            int x = (span1 / 5) * LocationUtil.RealTimeItem_Width;
            return x;
            }
        }
    }
}
